package com.sk.waste.app.application

import android.annotation.SuppressLint
import com.amap.api.location.AMapLocationClient
import com.lc.smc.lib.applications.LCApplication
import com.sk.waste.app.models.UserModel

class MyApplication : LCApplication() {

    private var application: MyApplication? = null
    private var userInfo: UserModel? = null
    private var currentLocation = ""

    companion object {
        @SuppressLint("StaticFieldLeak")
        val instance = SingletonHolder.holder
    }

    private object SingletonHolder {
        @SuppressLint("StaticFieldLeak")
        val holder = MyApplication()
    }

    override fun onCreate() {
        super.onCreate()
        application = this
        //定位隐私政策同意
        AMapLocationClient.updatePrivacyShow(this, true, true)
        AMapLocationClient.updatePrivacyAgree(this, true)
    }

    fun setUserInfo(user: UserModel) {
        userInfo = user
    }

    fun getUserInfo(): UserModel? {
        return userInfo
    }

    fun setLocaiton(location: String) {
        currentLocation = location
    }

    fun getLocaiton(): String {
        return currentLocation
    }

}